class: center, middle, inverse, title-slide .title[ # Geospatial Techniques for Social Scientists ] .subtitle[ ## Spatial Econometrics & Outlook ] .author[ ### Stefan Jünger ] .institute[ ###
Methods and Data Hub, Cluster of Excellence “The Politics of Inequality”
] .date[ ### July 15, 2022 ] --- layout: true --- ## Now <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 15 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## What are spatial econometrics? Econometrics could be reduced to simple statistics... - yet, it has a clearer connection to (economic) theory - this is also why it is interesting for causal inference and thinking Therefore, spatial econometrics combine spatial analysis and econometrics - study of why spatial relationships (i.e., autocorrelation) exist **What is the data generation process?** --- ## Spatial diffusion vs. spatial spillover There are at least two common mechanisms we are interested in spatial econometrics .pull-left[ **Diffusion** - `\(y_i\)` affects `\(y_j\)` through `\(w_{ij}\)` - `\(y_j\)` affects `\(y_i\)` through `\(w_{ji}\)` - that's a feedback effect - endogenous by design! ] .pull-right[ **Spillover** - `\(x_i\)` affects `\(y_j\)` through `\(w_{ij}\)` - `\(x_j\)` affects `\(y_i\)` through `\(w_{ij}\)` ] --- ## Let's have another look at our chessboard .pull-left[ We have to think about theory and mechanisms and how they translate into spatial effects and the data generation process. That said, there are tests to check for the specific data generation process at hand but they are not recommended to be used naively. ] .pull-right[ .center[ <img src="data:image/png;base64,#../img/queen_interdependent.png" width="3464" style="display: block; margin: auto;" /> ] ] --- ## Is it meaningful or just nuisance? Space can be important in our analysis in two ways. - it's meaningful in our theory and we thus interpret it accordingly after estimation - it can distort our empirical estimates producing bias, inconsistency and inefficiency **We can address both of these different perspectives in our analysis with spatial econometric methods.** --- ## Formulas... models, models, models Linear Regression: `$$Y = X\beta + \epsilon$$` -- Spatial Lag Y / Spatial Autoregressive Model: `$$Y = \rho WY + X\beta + \epsilon$$` -- Spatial Lag X Model: `$$Y = X\beta + WX\theta + \epsilon$$` -- Spatial Error Model: `$$Y = X\beta + u$$` `$$u = \lambda Wu + \epsilon$$` --- ## Flavors and estensions .small[ Spatial Durbin Model: $$Y = \rho WY + X\beta + WX\theta + \epsilon $$ ] -- .small[ Spatial Durbin Error Model: `$$Y = X\beta + WX\theta + u$$` `$$u = \lambda Wu + \epsilon$$` ] -- .small[ Combined Spatial Autocorrelation Model: `$$Y = \rho WY + X\beta + u$$` `$$u = \lambda Wu + \epsilon$$` ] -- .small[ Manski Model: `$$Y = \rho WY + WX\theta + X\beta + u$$` `$$u = \lambda Wu + \epsilon$$` ] --- ## Intermediate summary .pull-left[ There are a lot of models you could estimate to *explain* spatial autocorrelation. And there's a vast body of literature on what's the best choice for which application. I'd explicitly like to recommend you the work of [Tobias Rüttenauer](https://ruettenauer.github.io/publication/) (guy on the right) for us social scientists. [Here](https://ruettenauer.github.io/SICSS-Spatial/index.html) are some really nice workshop materials. ] .pull-right[ .center[ <img src="data:image/png;base64,#../img/at_home.png" width="2363" style="display: block; margin: auto;" /> ] ] **In this session, we will only estimate Spatial Lag Y and X and Spatial Error Models.** --- ## 'Research' question and data We will use the same example as in the previous session. But this time we will actually test if one of our spatal regression models helps in investigating the data generation process any further. We may ask: 1. Do immigrant shares have an effect on AfD voting shares within voting districts? 2. Do immigrant shares have an effect on AfD voting shares between neighborhoods? (=spillover) 3. Do AfD voting shares have an effect on AfD voting shares between neighborhoods? (=diffusion) It might also be a good idea to control for inhabitant numbers within the voting districts. ``` ## Reading layer `OGRGeoJSON' from data source ## `https://geoportal.stadt-koeln.de/arcgis/rest/services/Basiskarten/kgg/MapServer/20/query?where=objectid+is+not+null&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Foot&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=4326&havingClause=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&historicMoment=&returnDistinctValues=false&resultOffset=&resultRecordCount=&returnExtentOnly=false&datumTransformation=¶meterValues=&rangeValues=&quantizationParameters=&featureEncoding=esriDefault&f=geojson' ## using driver `GeoJSON' ## Simple feature collection with 543 features and 20 fields ## Geometry type: MULTIPOLYGON ## Dimension: XY ## Bounding box: xmin: 6.77253 ymin: 50.83045 xmax: 7.162028 ymax: 51.08496 ## Geodetic CRS: WGS 84 ``` ``` ## | | | 0% | |= | 0% | |= | 1% | |== | 1% | |== | 2% | |=== | 2% | |==== | 3% | |===== | 3% | |===== | 4% | |====== | 4% | |======= | 5% | |======== | 5% | |======== | 6% | |========= | 6% | |========== | 7% | |=========== | 7% | |=========== | 8% | |============ | 8% | |============ | 9% | |============= | 9% | |============== | 9% | |============== | 10% | |=============== | 10% | |=============== | 11% | |================ | 11% | |================= | 12% | |================== | 12% | |================== | 13% | |=================== | 13% | |==================== | 14% | |===================== | 14% | |===================== | 15% | |====================== | 15% | |======================= | 16% | |======================== | 16% | |======================== | 17% | |========================= | 17% | |========================= | 18% | |========================== | 18% | |=========================== | 18% | |=========================== | 19% | |============================ | 19% | |============================ | 20% | |============================= | 20% | |============================== | 21% | |=============================== | 21% | |=============================== | 22% | |================================ | 22% | |================================= | 23% | |================================== | 23% | |================================== | 24% | |=================================== | 24% | |==================================== | 25% | |===================================== | 25% | |===================================== | 26% | |====================================== | 26% | |====================================== | 27% | |======================================= | 27% | |======================================== | 27% | |======================================== | 28% | |========================================= | 28% | |========================================= | 29% | |========================================== | 29% | |=========================================== | 30% | |============================================ | 30% | |============================================ | 31% | |============================================= | 31% | |============================================== | 32% | |=============================================== | 32% | |=============================================== | 33% | |================================================ | 33% | |================================================ | 34% | |================================================= | 34% | |================================================== | 34% | |================================================== | 35% | |=================================================== | 35% | |=================================================== | 36% | |==================================================== | 36% | |===================================================== | 36% | |===================================================== | 37% | |====================================================== | 37% | |====================================================== | 38% | |======================================================= | 38% | |======================================================== | 39% | |========================================================= | 39% | |========================================================= | 40% | |========================================================== | 40% | |========================================================== | 41% | |=========================================================== | 41% | |============================================================ | 41% | |============================================================ | 42% | |============================================================= | 42% | |============================================================= | 43% | |============================================================== | 43% | |=============================================================== | 43% | |=============================================================== | 44% | |================================================================ | 44% | |================================================================ | 45% | |================================================================= | 45% | |================================================================== | 45% | |================================================================== | 46% | |=================================================================== | 46% | |=================================================================== | 47% | |==================================================================== | 47% | |==================================================================== | 48% | |===================================================================== | 48% | |====================================================================== | 48% | |====================================================================== | 49% | |======================================================================= | 49% | |======================================================================= | 50% | |======================================================================== | 50% | |========================================================================= | 50% | |========================================================================= | 51% | |========================================================================== | 51% | |========================================================================== | 52% | |=========================================================================== | 52% | |============================================================================ | 52% | |============================================================================ | 53% | |============================================================================= | 53% | |============================================================================= | 54% | |============================================================================== | 54% | |============================================================================== | 55% | |=============================================================================== | 55% | |================================================================================ | 55% | |================================================================================ | 56% | |================================================================================= | 56% | |================================================================================= | 57% | |================================================================================== | 57% | |=================================================================================== | 57% | |=================================================================================== | 58% | |==================================================================================== | 58% | |==================================================================================== | 59% | |===================================================================================== | 59% | |====================================================================================== | 59% | |====================================================================================== | 60% | |======================================================================================= | 60% | |======================================================================================= | 61% | |======================================================================================== | 61% | |========================================================================================= | 62% | |========================================================================================== | 62% | |========================================================================================== | 63% | |=========================================================================================== | 63% | |=========================================================================================== | 64% | |============================================================================================ | 64% | |============================================================================================= | 64% | |============================================================================================= | 65% | |============================================================================================== | 65% | |============================================================================================== | 66% | |=============================================================================================== | 66% | |================================================================================================ | 66% | |================================================================================================ | 67% | |================================================================================================= | 67% | |================================================================================================= | 68% | |================================================================================================== | 68% | |=================================================================================================== | 69% | |==================================================================================================== | 69% | |==================================================================================================== | 70% | |===================================================================================================== | 70% | |====================================================================================================== | 71% | |======================================================================================================= | 71% | |======================================================================================================= | 72% | |======================================================================================================== | 72% | |======================================================================================================== | 73% | |========================================================================================================= | 73% | |========================================================================================================== | 73% | |========================================================================================================== | 74% | |=========================================================================================================== | 74% | |=========================================================================================================== | 75% | |============================================================================================================ | 75% | |============================================================================================================= | 76% | |============================================================================================================== | 76% | |============================================================================================================== | 77% | |=============================================================================================================== | 77% | |================================================================================================================ | 78% | |================================================================================================================= | 78% | |================================================================================================================= | 79% | |================================================================================================================== | 79% | |=================================================================================================================== | 80% | |==================================================================================================================== | 80% | |==================================================================================================================== | 81% | |===================================================================================================================== | 81% | |===================================================================================================================== | 82% | |====================================================================================================================== | 82% | |======================================================================================================================= | 82% | |======================================================================================================================= | 83% | |======================================================================================================================== | 83% | |======================================================================================================================== | 84% | |========================================================================================================================= | 84% | |========================================================================================================================== | 85% | |=========================================================================================================================== | 85% | |=========================================================================================================================== | 86% | |============================================================================================================================ | 86% | |============================================================================================================================= | 87% | |============================================================================================================================== | 87% | |============================================================================================================================== | 88% | |=============================================================================================================================== | 88% | |================================================================================================================================ | 89% | |================================================================================================================================= | 89% | |================================================================================================================================= | 90% | |================================================================================================================================== | 90% | |================================================================================================================================== | 91% | |=================================================================================================================================== | 91% | |==================================================================================================================================== | 91% | |==================================================================================================================================== | 92% | |===================================================================================================================================== | 92% | |===================================================================================================================================== | 93% | |====================================================================================================================================== | 93% | |======================================================================================================================================= | 94% | |======================================================================================================================================== | 94% | |======================================================================================================================================== | 95% | |========================================================================================================================================= | 95% | |========================================================================================================================================== | 96% | |=========================================================================================================================================== | 96% | |=========================================================================================================================================== | 97% | |============================================================================================================================================ | 97% | |============================================================================================================================================= | 98% | |============================================================================================================================================== | 98% | |============================================================================================================================================== | 99% | |=============================================================================================================================================== | 99% | |=============================================================================================================================================== | 100% | |================================================================================================================================================| 100% ## | | | 0% | |= | 0% | |= | 1% | |== | 1% | |== | 2% | |=== | 2% | |==== | 3% | |===== | 3% | |===== | 4% | |====== | 4% | |======= | 5% | |======== | 5% | |======== | 6% | |========= | 6% | |========== | 7% | |=========== | 7% | |=========== | 8% | |============ | 8% | |============ | 9% | |============= | 9% | |============== | 9% | |============== | 10% | |=============== | 10% | |=============== | 11% | |================ | 11% | |================= | 12% | |================== | 12% | |================== | 13% | |=================== | 13% | |==================== | 14% | |===================== | 14% | |===================== | 15% | |====================== | 15% | |======================= | 16% | |======================== | 16% | |======================== | 17% | |========================= | 17% | |========================= | 18% | |========================== | 18% | |=========================== | 18% | |=========================== | 19% | |============================ | 19% | |============================ | 20% | |============================= | 20% | |============================== | 21% | |=============================== | 21% | |=============================== | 22% | |================================ | 22% | |================================= | 23% | |================================== | 23% | |================================== | 24% | |=================================== | 24% | |==================================== | 25% | |===================================== | 25% | |===================================== | 26% | |====================================== | 26% | |====================================== | 27% | |======================================= | 27% | |======================================== | 27% | |======================================== | 28% | |========================================= | 28% | |========================================= | 29% | |========================================== | 29% | |=========================================== | 30% | |============================================ | 30% | |============================================ | 31% | |============================================= | 31% | |============================================== | 32% | |=============================================== | 32% | |=============================================== | 33% | |================================================ | 33% | |================================================ | 34% | |================================================= | 34% | |================================================== | 34% | |================================================== | 35% | |=================================================== | 35% | |=================================================== | 36% | |==================================================== | 36% | |===================================================== | 36% | |===================================================== | 37% | |====================================================== | 37% | |====================================================== | 38% | |======================================================= | 38% | |======================================================== | 39% | |========================================================= | 39% | |========================================================= | 40% | |========================================================== | 40% | |========================================================== | 41% | |=========================================================== | 41% | |============================================================ | 41% | |============================================================ | 42% | |============================================================= | 42% | |============================================================= | 43% | |============================================================== | 43% | |=============================================================== | 43% | |=============================================================== | 44% | |================================================================ | 44% | |================================================================ | 45% | |================================================================= | 45% | |================================================================== | 45% | |================================================================== | 46% | |=================================================================== | 46% | |=================================================================== | 47% | |==================================================================== | 47% | |==================================================================== | 48% | |===================================================================== | 48% | |====================================================================== | 48% | |====================================================================== | 49% | |======================================================================= | 49% | |======================================================================= | 50% | |======================================================================== | 50% | |========================================================================= | 50% | |========================================================================= | 51% | |========================================================================== | 51% | |========================================================================== | 52% | |=========================================================================== | 52% | |============================================================================ | 52% | |============================================================================ | 53% | |============================================================================= | 53% | |============================================================================= | 54% | |============================================================================== | 54% | |============================================================================== | 55% | |=============================================================================== | 55% | |================================================================================ | 55% | |================================================================================ | 56% | |================================================================================= | 56% | |================================================================================= | 57% | |================================================================================== | 57% | |=================================================================================== | 57% | |=================================================================================== | 58% | |==================================================================================== | 58% | |==================================================================================== | 59% | |===================================================================================== | 59% | |====================================================================================== | 59% | |====================================================================================== | 60% | |======================================================================================= | 60% | |======================================================================================= | 61% | |======================================================================================== | 61% | |========================================================================================= | 62% | |========================================================================================== | 62% | |========================================================================================== | 63% | |=========================================================================================== | 63% | |=========================================================================================== | 64% | |============================================================================================ | 64% | |============================================================================================= | 64% | |============================================================================================= | 65% | |============================================================================================== | 65% | |============================================================================================== | 66% | |=============================================================================================== | 66% | |================================================================================================ | 66% | |================================================================================================ | 67% | |================================================================================================= | 67% | |================================================================================================= | 68% | |================================================================================================== | 68% | |=================================================================================================== | 69% | |==================================================================================================== | 69% | |==================================================================================================== | 70% | |===================================================================================================== | 70% | |====================================================================================================== | 71% | |======================================================================================================= | 71% | |======================================================================================================= | 72% | |======================================================================================================== | 72% | |======================================================================================================== | 73% | |========================================================================================================= | 73% | |========================================================================================================== | 73% | |========================================================================================================== | 74% | |=========================================================================================================== | 74% | |=========================================================================================================== | 75% | |============================================================================================================ | 75% | |============================================================================================================= | 76% | |============================================================================================================== | 76% | |============================================================================================================== | 77% | |=============================================================================================================== | 77% | |================================================================================================================ | 78% | |================================================================================================================= | 78% | |================================================================================================================= | 79% | |================================================================================================================== | 79% | |=================================================================================================================== | 80% | |==================================================================================================================== | 80% | |==================================================================================================================== | 81% | |===================================================================================================================== | 81% | |===================================================================================================================== | 82% | |====================================================================================================================== | 82% | |======================================================================================================================= | 82% | |======================================================================================================================= | 83% | |======================================================================================================================== | 83% | |======================================================================================================================== | 84% | |========================================================================================================================= | 84% | |========================================================================================================================== | 85% | |=========================================================================================================================== | 85% | |=========================================================================================================================== | 86% | |============================================================================================================================ | 86% | |============================================================================================================================= | 87% | |============================================================================================================================== | 87% | |============================================================================================================================== | 88% | |=============================================================================================================================== | 88% | |================================================================================================================================ | 89% | |================================================================================================================================= | 89% | |================================================================================================================================= | 90% | |================================================================================================================================== | 90% | |================================================================================================================================== | 91% | |=================================================================================================================================== | 91% | |==================================================================================================================================== | 91% | |==================================================================================================================================== | 92% | |===================================================================================================================================== | 92% | |===================================================================================================================================== | 93% | |====================================================================================================================================== | 93% | |======================================================================================================================================= | 94% | |======================================================================================================================================== | 94% | |======================================================================================================================================== | 95% | |========================================================================================================================================= | 95% | |========================================================================================================================================== | 96% | |=========================================================================================================================================== | 96% | |=========================================================================================================================================== | 97% | |============================================================================================================================================ | 97% | |============================================================================================================================================= | 98% | |============================================================================================================================================== | 98% | |============================================================================================================================================== | 99% | |=============================================================================================================================================== | 99% | |=============================================================================================================================================== | 100% | |================================================================================================================================================| 100% ``` --- ## Linear regression ```r linear_regression <- lm(afd_share ~ immigrant_share + inhabitants, data = election_results) summary(linear_regression) ``` ``` ## ## Call: ## lm(formula = afd_share ~ immigrant_share + inhabitants, data = election_results) ## ## Residuals: ## Min 1Q Median 3Q Max ## -15.0103 -3.3970 -0.2322 2.7901 25.0313 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 27.736716 0.579580 47.857 < 2e-16 *** ## immigrant_share -0.097657 0.026150 -3.735 0.000208 *** ## inhabitants -0.079594 0.003812 -20.879 < 2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 4.843 on 540 degrees of freedom ## Multiple R-squared: 0.4822, Adjusted R-squared: 0.4803 ## F-statistic: 251.4 on 2 and 540 DF, p-value: < 2.2e-16 ``` --- ## Now we need a spatial weight To estimate a spatial regression we, once again, have to construct a spatial weight as in the analysis of spatial autocorrelation. In fact, we'll use the same approach as before. ```r queen_neighborhoods <- spdep::poly2nb(election_results, queen = TRUE) queen_W <- spdep::nb2listw(queen_neighborhoods, style = "W") ``` --- ## Spatial Error Model: If we want to control nuisance .small[ ```r spatial_error_model <- spatialreg::errorsarlm( afd_share ~ immigrant_share + inhabitants, data = election_results, listw = queen_W ) summary(spatial_error_model) ``` ``` ## ## Call:spatialreg::errorsarlm(formula = afd_share ~ immigrant_share + inhabitants, data = election_results, listw = queen_W) ## ## Residuals: ## Min 1Q Median 3Q Max ## -9.59881 -2.37778 -0.40472 1.98079 25.55916 ## ## Type: error ## Coefficients: (asymptotic standard errors) ## Estimate Std. Error z value Pr(>|z|) ## (Intercept) 22.8200754 0.9376563 24.3374 < 2.2e-16 ## immigrant_share -0.0807211 0.0281310 -2.8695 0.004112 ## inhabitants -0.0338967 0.0045688 -7.4192 1.179e-13 ## ## Lambda: 0.75615, LR test value: 215.08, p-value: < 2.22e-16 ## Asymptotic standard error: 0.033152 ## z-value: 22.809, p-value: < 2.22e-16 ## Wald statistic: 520.25, p-value: < 2.22e-16 ## ## Log likelihood: -1518.01 for error model ## ML residual variance (sigma squared): 13.567, (sigma: 3.6833) ## Number of observations: 543 ## Number of parameters estimated: 5 ## AIC: 3046, (AIC for lm: 3259.1) ``` ] --- ## Spatial Lag X Model: estimating spillovers .small[ ```r spatial_lag_x_model <- spatialreg::lmSLX( afd_share ~ immigrant_share + inhabitants, data = election_results, listw = queen_W ) summary(spatial_lag_x_model) ``` ``` ## ## Call: ## lm(formula = formula(paste("y ~ ", paste(colnames(x)[-1], collapse = "+"))), ## data = as.data.frame(x), weights = weights) ## ## Residuals: ## Min 1Q Median 3Q Max ## -10.4185 -3.0279 -0.1934 2.4599 25.0712 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 30.631405 0.671337 45.627 < 2e-16 *** ## immigrant_share -0.069768 0.034635 -2.014 0.0445 * ## inhabitants -0.026529 0.005839 -4.543 6.84e-06 *** ## lag.immigrant_share -0.025644 0.048159 -0.532 0.5946 ## lag.inhabitants -0.085156 0.007644 -11.141 < 2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 4.365 on 538 degrees of freedom ## Multiple R-squared: 0.5809, Adjusted R-squared: 0.5778 ## F-statistic: 186.5 on 4 and 538 DF, p-value: < 2.2e-16 ``` ] --- ## Spatial Lag Y Model: estimating diffusion .small[ ```r spatial_lag_y_model <- spatialreg::lagsarlm( afd_share ~ immigrant_share + inhabitants, data = election_results, listw = queen_W) summary(spatial_lag_y_model) ``` ``` ## ## Call:spatialreg::lagsarlm(formula = afd_share ~ immigrant_share + inhabitants, data = election_results, listw = queen_W) ## ## Residuals: ## Min 1Q Median 3Q Max ## -10.17075 -2.27107 -0.28311 1.98468 24.27406 ## ## Type: lag ## Coefficients: (asymptotic standard errors) ## Estimate Std. Error z value Pr(>|z|) ## (Intercept) 10.2849510 0.9788424 10.5073 < 2e-16 ## immigrant_share -0.0531561 0.0197071 -2.6973 0.00699 ## inhabitants -0.0332005 0.0034302 -9.6789 < 2e-16 ## ## Rho: 0.66331, LR test value: 260.31, p-value: < 2.22e-16 ## Asymptotic standard error: 0.034898 ## z-value: 19.007, p-value: < 2.22e-16 ## Wald statistic: 361.27, p-value: < 2.22e-16 ## ## Log likelihood: -1495.397 for lag model ## ML residual variance (sigma squared): 13.013, (sigma: 3.6073) ## Number of observations: 543 ## Number of parameters estimated: 5 ## AIC: 3000.8, (AIC for lm: 3259.1) ## LM test for residual autocorrelation ## test value: 21.574, p-value: 3.4043e-06 ``` ] --- ## Comparison: What's 'better'? .small[ ```r AIC(spatial_error_model, spatial_lag_x_model, spatial_lag_y_model) ``` ``` ## df AIC ## spatial_error_model 5 3046.019 ## spatial_lag_x_model 6 3148.184 ## spatial_lag_y_model 5 3000.794 ``` ```r spdep::lm.LMtests(linear_regression, queen_W, test = c("LMerr", "LMlag")) ``` ``` ## ## Lagrange multiplier diagnostics for spatial dependence ## ## data: ## model: lm(formula = afd_share ~ immigrant_share + inhabitants, data = election_results) ## weights: queen_W ## ## LMerr = 197.05, df = 1, p-value < 2.2e-16 ## ## ## Lagrange multiplier diagnostics for spatial dependence ## ## data: ## model: lm(formula = afd_share ~ immigrant_share + inhabitants, data = election_results) ## weights: queen_W ## ## LMlag = 298.33, df = 1, p-value < 2.2e-16 ``` ] Let's stick to our theory, shall we? --- ## Of higher importance: interpretation Unfortunately, in case of a Spatial Lag X Model the spatial parameter `\(\rho\)` only tells us that the effect is (statistically) significant -- or not. - remember: these models are endegenous by design - we have effects of `\(y_j\)` on `\(y_i\)` and vice versa - what a mess Luckily, there's a method to decompose the spatial effects into direct, indirect and total effects: **estimating impacts** - it's also helpful for Spatial Lag X Models --- ## Impact estimation in `R` This time, let's start with the Spatial Lag Y Model: ```r spatialreg::impacts(spatial_lag_y_model, listw = queen_W) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.05999312 -0.09788693 -0.15788005 ## inhabitants -0.03747085 -0.06113877 -0.09860962 ``` Compare it to the 'simple' regression output: ```r coef(spatial_lag_y_model) ``` ``` ## rho (Intercept) immigrant_share inhabitants ## 0.66331353 10.28495095 -0.05315608 -0.03320052 ``` --- ## Spatial Lag X impacts ```r spatialreg::impacts(spatial_lag_x_model, listw = queen_W) ``` ``` ## Impact measures (SlX, estimable): ## Direct Indirect Total ## immigrant_share -0.06976773 -0.02564443 -0.09541216 ## inhabitants -0.02652893 -0.08515589 -0.11168482 ``` Compare it to the 'simple' regression output: ```r coef(spatial_lag_x_model) ``` ``` ## (Intercept) immigrant_share inhabitants lag.immigrant_share lag.inhabitants ## 30.63140484 -0.06976773 -0.02652893 -0.02564443 -0.08515589 ``` --- ## If you need p-values and stuff ```r spatialreg::impacts(spatial_lag_y_model, listw = queen_W, R = 500) %>% summary(zstats = TRUE, short = TRUE) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.05999312 -0.09788693 -0.15788005 ## inhabitants -0.03747085 -0.06113877 -0.09860962 ## ======================================================== ## Simulation results ( variance matrix): ## ======================================================== ## Simulated standard errors ## Direct Indirect Total ## immigrant_share 0.023035434 0.039378529 0.06135663 ## inhabitants 0.003473739 0.007733647 0.00922084 ## ## Simulated z-values: ## Direct Indirect Total ## immigrant_share -2.589302 -2.491245 -2.57099 ## inhabitants -10.853669 -8.026227 -10.82058 ## ## Simulated p-values: ## Direct Indirect Total ## immigrant_share 0.0096171 0.01273 0.010141 ## inhabitants < 2.22e-16 1.1102e-15 < 2e-16 ``` --- class: middle ## Exercise 2_3_2: Spatial Regression [Exercise](https://stefanjuenger.github.io/gis_socsci_konstanz/exercises/2_3_2_Spatial_Regression.html) [Solution](https://stefanjuenger.github.io/gis_socsci_konstanz/solutions/2_3_2_Spatial_Regression.html) --- ## What if you got missing values? Missing values in spatial regression models does produce similar problems as in ordinary regression analysis - yield biased estimates - reduces statistical power However, the issue gets a bit more severe as the observations interdependent - we are missing out more information - even randomness of missings might get problematic - **Thus, it might be a good idea to think of methods to navigate this bias.** --- ## Let's produce a dataset with missing data .pull-left[ ```r # ~10% missing values missing_index <- sample( 1:nrow(election_results), round(nrow(election_results) * .1, 0) ) election_results_missing <- election_results election_results_missing$afd_share[missing_index] <- NA # list-wise deletion election_results_missing <- na.omit(election_results_missing) tm_shape(election_results_missing) + tm_fill("afd_share", palette = "viridis") ``` ] .pull-right[ .center[ <img src="data:image/png;base64,#2_4_Spatial_Econometrics_Outlook_files/figure-html/missing-elections-2-1.png" style="display: block; margin: auto;" /> ] ] --- ## How does a Spatial Lag X Model perform? ```r queen_neighborhoods_missing <- spdep::poly2nb(election_results_missing, queen = TRUE) queen_W_missing <- spdep::nb2listw(queen_neighborhoods_missing, style = "W", zero.policy = TRUE) spatial_lag_y_model_missing <- spatialreg::lagsarlm( afd_share ~ immigrant_share + inhabitants, data = election_results_missing, listw = queen_W_missing, zero.policy = TRUE ) ``` --- ## Model comparison ```r spatialreg::impacts(spatial_lag_y_model_missing, listw = queen_W_missing) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.07692457 -0.11695008 -0.19387464 ## inhabitants -0.03716533 -0.05650325 -0.09366857 ``` ```r spatialreg::impacts(spatial_lag_y_model, listw = queen_W) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.05999312 -0.09788693 -0.15788005 ## inhabitants -0.03747085 -0.06113877 -0.09860962 ``` --- ## What to do now? The way how to deal with missing data in geospatial data depends on their general geometric structure. For points, there are established methods, such as [interpolation](https://keen-swartz-3146c4.netlify.app/interpolation.html). Often these are somewhat ways of aggregating data, which does not help in our case. I'd say that good old imputation techniques might also help: - good for multivariate cases - yet, they are no spatial techniques and cannot create plausible values for spatial relationships - but imputing spatial relationships would be a matter of contingency anyway --- ## Simplest case of imputation .pull-left[ ```r # ~10% missing values missing_index <- sample( 1:nrow(election_results), round(nrow(election_results) * .1, 0) ) election_results_missing <- election_results election_results_missing$afd_share[missing_index] <- NA election_results_missing$afd_share[missing_index] <- mean(election_results_missing$afd_share, na.rm = TRUE) ``` ] .pull-right[ .center[ ``` ## ## iter imp variable ## 1 1 afd_share ## 2 1 afd_share ## 3 1 afd_share ## 4 1 afd_share ## 5 1 afd_share ``` <img src="data:image/png;base64,#2_4_Spatial_Econometrics_Outlook_files/figure-html/mean-impute-2-1.png" style="display: block; margin: auto;" /> ] ] --- ## And again run the model ```r queen_neighborhoods_missing <- spdep::poly2nb(election_results_missing, queen = TRUE) queen_W_missing <- spdep::nb2listw(queen_neighborhoods_missing, style = "W") spatial_lag_y_model_missing <- spatialreg::lagsarlm( afd_share ~ immigrant_share + inhabitants, data = election_results_missing, listw = queen_W_missing ) ``` --- ## ...and compare it with the original one ```r spatialreg::impacts(spatial_lag_y_model_missing, listw = queen_W_missing) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.05941438 -0.07394132 -0.13335569 ## inhabitants -0.04285152 -0.05332881 -0.09618033 ``` ```r spatialreg::impacts(spatial_lag_y_model, listw = queen_W) ``` ``` ## Impact measures (lag, exact): ## Direct Indirect Total ## immigrant_share -0.05999312 -0.09788693 -0.15788005 ## inhabitants -0.03747085 -0.06113877 -0.09860962 ``` --- class: middle ## Outlook --- ## This week <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Introduction <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 14 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Introduction Main Messages - Geospatial data are relevant in the social sciences - already for a long time - `R` can serve as a full-blown Geographic Information System (GIS) --- ## Vector Data <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 14 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Vector Data Main Messages - Most common geospatial data type - Vector data come as points, lines or polygons - Information on the geometries stored in the geometry column - Attributes can be assigned to each geometric object - Attribute tables are treated as data frames --- ## Mapping <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 14 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Mapping Main Messages - basis of each map is the geometries of geospatial data - spatial distribution of attributes become visible when defining an attribute and adding color scales - layer shapefiles to add more information or for aesthetic reasons --- ## Raster Data <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solidbackground-color: yellow !important;"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solidbackground-color: yellow !important;"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solidbackground-color: yellow !important;"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Raster Data Main Messages - Data format for efficient and fast analysis of geospatial data - flexible in their application - can get rather involved - however, straightforward extraction of values --- ## Advanced Data Import <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 15 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Advanced Data Import Main Messages - Geospatial data tend to be large - Often distributed over the internet - APIs help in downloading these data - can get pretty involved --- ## Applied Data Wrangling <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 15 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Applied Data Wrangling Main Messages - Georeferenced survey data require handling sensitive data - our example of wrangling and linking data (applications may vary) - spatial joins are the perfect tool to add geospatial information to other georeferenced data --- ## Investigating Spatial Autocorrelation <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 15 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Investigating Spatial Autocorrelation Main Messages - spatial autocorrelation is something that must be detected - we need a model for that - spatial weight matrices! - there are global and local indicators of spatial autocorrelation --- ## Spatial Econometrics <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Title </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:30am </td> <td style="text-align:left;font-weight: bold;"> Introduction to GIS </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 10:30am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Vector Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 14 </td> <td style="text-align:left;color: gray !important;"> 01:00pm-02:30pm </td> <td style="text-align:left;font-weight: bold;"> Mapping </td> </tr> <tr> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> July 14 </td> <td style="text-align:left;color: gray !important;border-bottom: 1px solid"> 02:30pm-04:00pm </td> <td style="text-align:left;font-weight: bold;border-bottom: 1px solid"> Raster Data </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 09:00am-10:00am </td> <td style="text-align:left;font-weight: bold;"> Advanced Data Import & Processing </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 10:00am-11:00am </td> <td style="text-align:left;font-weight: bold;"> Applied Data Wrangling & Linking </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;"> 11:00am-12:00pm </td> <td style="text-align:left;font-weight: bold;"> Investigating Spatial Autocorrelation </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> July 15 </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:00pm-01:00pm </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> July 15 </td> <td style="text-align:left;color: gray !important;background-color: yellow !important;"> 01:00pm-02:45pm </td> <td style="text-align:left;font-weight: bold;background-color: yellow !important;"> Spatial Econometrics & Outlook </td> </tr> </tbody> </table> --- ## Spatial Econometrics Main Messages - spatial autocorrelation ca also be explained by - diffusion - or spillover effect - these effects can be tested but should always be inspected with theory - be careful when there are missing data --- ## What's left Other map types such as - cartograms - hexagon maps - animated maps - (more) network graphs -- GIS techniques, such as - geocoding - routing - cluster analysis -- More data sources... --- ## Data Sources Some more information: - geospatial data are interdisciplinary - amount of data feels unlimited - data providers and data portals are often specific in the area and/or the information they cover -- Some random examples: - [Eurostat](https://ec.europa.eu/eurostat/web/gisco/geodata) - [European Spatial Data Infrastructure](https://inspire.ec.europa.eu/about-inspire/563) - [John Hopkins Corona Data Hub and Dashboard](https://coronavirus.jhu.edu/map.html) - [US Census Bureau](https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html) - ... --- layout: false class: center background-image: url(data:image/png;base64,#../assets/img/the_end.png) background-size: cover .left-column[ </br> <img src="data:image/png;base64,#../img/Stefan.png" width="75%" style="display: block; margin: auto;" /> ] .right-column[ .left[.small[<svg viewBox="0 0 512 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm0 48v40.805c-22.422 18.259-58.168 46.651-134.587 106.49-16.841 13.247-50.201 45.072-73.413 44.701-23.208.375-56.579-31.459-73.413-44.701C106.18 199.465 70.425 171.067 48 152.805V112h416zM48 400V214.398c22.914 18.251 55.409 43.862 104.938 82.646 21.857 17.205 60.134 55.186 103.062 54.955 42.717.231 80.509-37.199 103.053-54.947 49.528-38.783 82.032-64.401 104.947-82.653V400H48z"></path> </svg> [stefan.juenger@gesis.org](mailto:stefan.juenger@gesis.org)] .small[<svg viewBox="0 0 512 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path> </svg> [`@StefanJuenger`](https://twitter.com/StefanJuenger)] .small[<svg viewBox="0 0 496 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path> </svg> [`StefanJuenger`](https://github.com/StefanJuenger)] .small[<svg viewBox="0 0 576 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"></path> </svg> [`https://stefanjuenger.github.io`](https://stefanjuenger.github.io)]] ]